const app = getApp()
Component({
  properties: {
    navbarData: Object
  },
  data: {
    share: 0,
    height: app.globalData.height,//设备顶部窗口的高度
    titleBarHeight: app.globalData.titleBarHeight,//标题栏高度
    navHeight: app.globalData.navHeight - 2,
    //默认值  默认显示左上角
    // navbarData: {
    //   showCapsule: 1
    // }
  },
  attached: function () {
    // 获取是否是通过分享进入的小程序
    // 定义导航栏的高度   方便对齐
    // var that = this
    // wx.getSystemInfo({
    //   success: function (res) {
    //     that.data.height = res.statusBarHeight
    //     that.data.titleBarHeight = (wx.getMenuButtonBoundingClientRect().bottom - res.statusBarHeight - wx.getMenuButtonBoundingClientRect().height) * 2 + wx.getMenuButtonBoundingClientRect().height
    //   },
    // })
    this.setData({
      height: app.globalData.height,
      titleBarHeight: app.globalData.titleBarHeight,
    })
    // console.log(getCurrentPages())
    // && getCurrentPages()[0].route == 'packageA/pages/activity/activity'
    if (getCurrentPages().length == 1) {
      this.setData({
        share: 1
      })
    } else {
      this.setData({
        share: 0
      })
    }
  },

  methods: {
    // 返回上一页面
    navback: function () {
      // if (getCurrentPages()[0].route === 'shop/pages/inviteStore/inviteStore') {
      //   wx.navigateBack({
      //     delta: getCurrentPages().length
      //   })
      // } else {
      //   wx.navigateBack()
      // }
      if (getCurrentPages()[getCurrentPages().length-1].route == "packageD/pages/wangYe/wangYe"||getCurrentPages()[getCurrentPages().length-1].route == "packageD/pages/empress/empress") {
        wx.switchTab({
          url: '/pages/index/index',
        })
      }else {
        wx.navigateBack()
      }
     
    },
    //返回到首页和店铺主页
    backhome: function () {
      wx.switchTab({
        url: '/pages/index/index',
      })
      // if (getCurrentPages()[0].route == "shop/pages/shopGift/shopGift") {
      //   wx.switchTab({
      //     url: '/pages/index/index',
      //   })
      // } else {
      //   wx.navigateTo({
      //     url: '/shop/pages/home/home',
      //   })
      // }

    }
  }

}) 